#include <REGX52.H>
#include "delay.h"

unsigned char ClumnArr[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
sbit RCK = P3^5;	//RCLK
sbit SCK = P3^6;	//SRCLK
sbit SER = P3^4;	//SER

void delay_10us(unsigned int ten_us)
{
	while(ten_us--);	
}

void _74HC595_WriteByte(unsigned char value)
{
	unsigned char i;
	//SER = value&0x80;
	//SCK = 1;
	//SCK = 0;
	//SER = value&0x40;
	//SCK = 1;
	//SCK = 0;
	for(i=0;i<8;i++)
	{
		SER = value&(0x80>>i);
		SCK = 1;
		SCK = 0;
	}
	RCK = 1;
	RCK = 0;
}

void MatrixLED_ShowColumn(unsigned char Column,Data)
{
	_74HC595_WriteByte(Data);
	//if(Column==0){P0 = ~0x80;}
	P0 = ~(0x80>>Column);
	//delay(600);
	delay_10us(1);
	P0 = 0xFF;
}

void main()
{
	unsigned int j = 0;
	SCK = 0;
	RCK = 0;
	while(1)
	{
		for(j=0;j<8;j++)
		{
			MatrixLED_ShowColumn(j,ClumnArr[j]);
		}
	}
}
